<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>servlet checkcode</title>
<script type="text/javascript">
	function reloadCode() {
		//发送请求时后面跟上时间或者一个随机数以确保浏览器能够正常响应
		//如果多次请求的内容是相同的,浏览器会认为是同一个请求直接无视
		var time = new Date().getTime();
		document.getElementById("imagecode").src="ImageServlet?d="+time;
	}
</script>
</head>
  
 <body>
 	<form action="LoginServlet" method="get">
   		验证码:<input type="text" name="checkcode">
   		<!--图片从Servlet读取,所以src为对应Servlet-->
   		<img alt="验证码" id="imagecode" src="ImageServlet">
   		<a href="javascript:reloadCode()">看不清楚</a><br>
   		<input type="submit" value="确定">
   </form>
 </body>
</html>